﻿using System;
using System.Collections.Generic;
using System.Linq;
using WebUI.BL.News;
using WebUI.Models;

namespace WebUI.AdminSite.News
{
    public partial class NewsCategory : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                ShowDataGridView();
            }
        }

        private void ShowDataGridView()
        {
            grdNewsCategory.DataSource = GetNewsCategories();
            grdNewsCategory.DataBind();
        }

        private List<NewsCategoryModelView> GetNewsCategories()
        {
            int index=1;
            NewsCategoryBL repository = new NewsCategoryBL();
            var newsCategories = from n in repository.GetNewCategories()
                                 select new NewsCategoryModelView
                                 {
                                     ID=index++,
                                     No=n.CategoryNo,
                                     NameVi= n.CategoryName,
                                     Status=n.Status,
                                 };
            return newsCategories.ToList();
        }

        protected void btnCreate_Click(object sender, EventArgs e)
        {
            //Response.Redirect(Helpers.link.toAdminNewsCatalog("NewCategoryCreate.aspx"));
        }
    }
}